home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 3_0 / OIC_1 / TESTWIND.C < prev    next >
Text File  |  1989-02-19  |  2KB  |  88 lines

  1. /*    
  2.  *        Macintosh Window abstract class
  3.  *
  4.  *        OIC-based access to the Mac Toolbox window manager. 
  5.  *
  6.  *            Copyright ⌐ John Wainwright 1988
  7.  *
  8.  *    MetaClass :
  9.  *
  10.  *    SuperClasses :
  11.  *
  12.  *  Instance Vars :
  13.  *
  14.  *    Class Vars :
  15.  *    
  16.  *    Methods :
  17.  *
  18.  *    Class Methods :
  19.  *
  20.  */
  21.  
  22. #include "oic.h"
  23. #include "generics.h"
  24.  
  25. class         Window;                /* the Window class                         */
  26.  
  27. struct window_i                    /* Window instance structure                 */
  28. {
  29.     WindowPtr    window;            /* the Mac window structure                    */
  30. };
  31. typedef struct window_i window_i;
  32.  
  33. enum { TITLE = 1, BOUNDS, KIND };        /* "new" keyword args                */
  34.  
  35. /* -------------------- Window Instance methods --------------------------- */
  36.  
  37. static object
  38. _new(self, w, wa)
  39.     object                    self;
  40.     register window_i        *w;
  41.     register keyword_args    wa;
  42. {
  43.     w->window = NewWindow(NULL, key_arg(wa, BOUNDS, NULL),
  44.                                 key_arg(wa, TITLE, "Untitled"),
  45.                                 -1,
  46.                                 (int)key_arg(wa, KIND, 1L),
  47.                                 -1L, 1, self);
  48.  
  49.     return Super(self, END);
  50. }
  51.  
  52. static
  53. _draw(self, w)
  54.     object        self;
  55.     window_i    *w;
  56. {
  57.     object        contents, item;
  58.     
  59.     SetPort(w->window);
  60.     EraseRect(&w->window->portRect);
  61.     for (contents = sequence(self); item = next(contents); )
  62.         draw(item);
  63. }
  64.  
  65. static object
  66. _repList(self)
  67.     object        self;
  68. {
  69.     register replist    replist;
  70.  
  71.     replist = New(Replist, "{", "}", ":");
  72.     add(replist, className(self),  Super(self), END);
  73.     return replist;
  74. }
  75.  
  76. /* ------------------- Init the Window class ------------------------------- */
  77.  
  78. InitWindowClass()
  79. {
  80.     Window = NewClass(sizeof(window_i), 0, "Window", List, END);
  81.     AddMethods(Window,
  82.         newGeneric,             _new,
  83.         drawGeneric,            _draw,
  84.         repListGeneric,            _repList,
  85.         END);
  86. }
  87.  
  88.